<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<%
	String path = request.getContextPath();
%>
<title>报表设置</title>
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/style.css" />

<script type="text/javascript"
	src="<%=path%>/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/extjs/ext-all.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
	<div id="west-div" style="width: 100%; height: 100%;"></div>
	<div id="center-div"></div>
</body>
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = "<%=path%>/extjs/resources/images/default/s.gif";

	Ext.onReady(function() {
				Ext.QuickTips.init();
				
				// shorthand
				var Tree = Ext.tree;
				var loader = new Tree.TreeLoader({
					dataUrl : 'column!findColumnTree.do'
				});
				loader.on("beforeload", function(treeLoader, node) {
					loader.baseParams.fflag = "1";//报表类型树
					//loader.baseParams.fcode  = node.attributes.fcode;
				}, this);

				loader.processResponse = function(response, node, callback) {
					var json1 = response.responseText;
					try {
						var json = eval("(" + json1 + ")");
						node.beginUpdate();
						//从json中取得json数组
						var o = json["key"];
						for ( var i = 0, len = o.length; i < len; i++) {
							var n = this.createNode(o[i]);
							if (n) {
								node.appendChild(n);
							}
						}
						node.endUpdate();
						if (typeof callback == "function") {
							callback(this, node);
						}
					} catch (e) {
						this.handleFailure(response);
					}
				};

				var tree = new Tree.TreePanel({
					region : 'center',
					id : 'west-panel',
					el : 'west-div',
					width : 280,
					//	title : '所属区县',
					useArrows : true,
					autoScroll : true,
					animate : true,
					enableDD : true,
					containerScroll : true,
					rootVisible : false, //树根不可见
					loader : loader
				});

				//单击事件
				tree.on('click', function(node) {
					if (node.isLeaf()) { //是报表
						//window.parent.loadNewPanel("99", "报表统计-" + node.text,
						//		"table_show.jsp", "report/table");
					
						if(node.attributes.fflag == "9") {
							window.parent.loadNewPanel(node.id, node.text,
									node.id + ".jsp?fbh="+node.id, "menu/xtgl");
						
						} else if(node.attributes.fflag == "8") {
							window.parent.loadNewPanel(node.id, node.text,
									node.id + ".jsp?fbh="+node.id, "menu/xtsz");
						} else {
							window.parent.loadNewPanel(node.id, node.text,
									node.id + ".jsp?fbh="+node.id, "mould_published");
							
						}
						
					}
				}, tree);

				// set the root node
				var root = new Tree.AsyncTreeNode({
					text : '所有报表',
					draggable : false,
					id : '0',
					fbh : '-1',
					ftype : '1'
				});
				tree.setRootNode(root);
				
				var btn_refresh_tree = new Ext.Button({
					text : '刷新',
					iconCls : 'sy-refresh',
					handler : function() {
						tree.root.reload();
					}
				});

				var tree_nav = new Ext.Panel({
					//title : '信息',
					region : 'center',
					// split : true,
					width : 320,
					layout : 'fit',
					autoScroll : true,
					collapsible : false,
					//tbar : [ btn_refresh_tree],
					items : [ tree ]
				});

				/************************************* 所属区县树 结束 ********************************************************/
				var viewport = new Ext.Viewport({
					layout : 'border',
					items : [ tree_nav ]
				});
			});
</script>


</html>